package cn.jiyun.service.impl;

import cn.jiyun.common.ReverseGeocodingService;
import cn.jiyun.entity.Dw;
import cn.jiyun.entity.Fw;
import cn.jiyun.mapper.DwMapper;
import cn.jiyun.mapper.FwMapper;
import cn.jiyun.entity.Fw;
import cn.jiyun.service.FwService;
import cn.jiyun.service.FwService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 31511
* @description 针对表【fw】的数据库操作Service实现
* @createDate 2024-10-29 09:26:40
*/
@Service
public class FwServiceImpl extends ServiceImpl<FwMapper, Fw>
    implements FwService {
    @Autowired
private FwMapper fwMapper;
    @Autowired
    private DwMapper dwMapper;
    @Autowired
    private ReverseGeocodingService reverseGeocodingService;
    @Override
    public Page<Fw> findPage(Integer pageNum, Integer pageSize, Fw fw) {

        Page<Fw> ffwPage = new Page<>(pageNum, pageSize);
        return fwMapper.findPage(ffwPage,fw);
    }

    @Override
    public Fw findId(Integer id) {
        Fw fw = fwMapper.selectById(id);
        String address = reverseGeocodingService.getAddressByCoordinates(fw.getLongitude(),fw.getDimensionality());
        fw.setAddress(address);
        Dw dw = dwMapper.selectById(fw.getDid());
        dw.setQjdate(new Date());
        fw.setQjshijian(dw.getQjdate());
        return fw;
    }
}




